﻿// See https://aka.ms/new-console-template for more information
using Microsoft.Extensions.AI;

Console.WriteLine("Hello, World!");

//创建终结点
Uri uri = new Uri("http://localhost:11434");

string model = "qwen2:7b";

//创建对话客户端
OllamaChatClient client = new OllamaChatClient(uri,model);

List<ChatMessage> messages = new List<ChatMessage>();
while (true)
{
	Console.Write("请输入问题：");

	string msg = Console.ReadLine();
	
	//创建一个消息对象
	ChatMessage chatMessage = new ChatMessage(ChatRole.User, msg);
	messages.Add(chatMessage);
	//通过对话客户端将消息发送给大模型
	var response = await client.GetResponseAsync(messages);
	messages.Add(new ChatMessage(ChatRole.Assistant, response.Text));

	Console.WriteLine(response.Text); 
}